﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2.CheckIfBracketsArePutCorrectly
{
    class CheckIfBracketsArePutCorrectly
    {
        static void Main(string[] args)
        {
            string expression = ")((a+b).";
            Console.WriteLine(expression);
            int openCount = 0;
            int closeCount = 0;
            for (int i = 0; i < expression.Length; i++)
            {
                if (expression[i]=='(')
                {
                    openCount++;
                }
                if (expression[i]==')')
                {
                    closeCount++;
                }
            }
            if (openCount == closeCount & expression.LastIndexOf('(') < expression.LastIndexOf(')') & expression.IndexOf('(') < expression.IndexOf(')'))
            {
                Console.WriteLine("The brackets in the expression are put correctly");
            }
            else
            {
                Console.WriteLine("The brackets in the expression are not put correctly");
            }
        }
    }
}
